<?php

/**
 * 页面展示
 */

namespace app\page\common;

class IndexCommon extends \app\index\common\IndexCommon {

    protected function index() {


        $classId = request('get', 'id');

        $pageParams = [];
        $pageInfo = target('page/Page')->getInfo($classId);
        if (empty($pageInfo)) {
            $this->error404();
        }
        if ($pageInfo['url']) {
            $this->redirect($pageInfo['url']);
        }
        $this->pageInfo['name'] = $pageInfo['name'];
        $this->setMeta($pageInfo['name']);

        $crumb = target('page/Page')->loadCrumbList($classId);
        $this->setCrumb($crumb);

        $pageParams['id'] = $classId;


        $tpl = 'page';
        if ($pageInfo['tpl']) {
            $tpl = $pageInfo['tpl'];
        }
        $parentPageInfo = array_slice($crumb, -2, 1);
        if (empty($parentPageInfo)) {
            $parentPageInfo = $crumb[0];
        } else {
            $parentPageInfo = $parentPageInfo[0];
        }
        $topPageInfo = $crumb[0];


        $this->assign('info', $pageInfo);
        $this->assign('parentPageInfo', $parentPageInfo);
        $this->assign('topPageInfo', $topPageInfo);

        $this->assign('pageParams', $pageParams);
        $this->siteDisplay($tpl);
    }



}